import request from '@/utils/request'

enum Api {
  //获取spu列表api
  getSpuListApi = '/admin/product',
  // 获取品牌列表api
  getTrademarkListApi = '/admin/product/baseTrademark/getTrademarkList',
  //获取销售属性api
  getBaseSaleAttrListApi = '/admin/product/baseSaleAttrList',
  //添加spu的Api
  postSaveSpuApi = '/admin/product/saveSpuInfo',
  //删除spu的api
  deleteOneSpuApi = '/admin/product/deleteSpu',
  //获取已上传的spu图片api
  getSpuImgListApi = "/admin/product/spuImageList",
  //获取已上传的spu销售属性api
  getSpuSaleAttrListApi = "/admin/product/spuSaleAttrList",
  // 更新spu请求api
  updateSpuInfoApi = "/admin/product/updateSpuInfo"
}

//获取spu列表请求
export const reqGetSpuListData = (
  page: number,
  limit: number,
  category3Id: number
) => {
  return request.get<any, any>(
    `${Api.getSpuListApi}/${page}/${limit}?category3Id=${category3Id}`
  )
}

//获取品牌列表请求
export const reqGetTrademarkList = () => {
  return request.get<any, any>(Api.getTrademarkListApi)
}

//获取销售属性请求
export const reqGetBaseSaleAttrList = () => {
  return request.get<any, any>(Api.getBaseSaleAttrListApi)
}

//添加spu请求
export const reqSaveSpu = (spuInfo) => {
  return request.post<any, null>(Api.postSaveSpuApi, spuInfo)
}

//请求删除一条spu
export const reqDelOneSpu = (spuId:number)=>{
  return request.delete<any, null>(`${Api.deleteOneSpuApi}/${spuId}`)
}

//获取已上传的spu图片列表
export const reqSpuImgListData = (spuId:number)=>{
  return request.get<any,any>(`${Api.getSpuImgListApi}/${spuId}`)
}

//获取已上传的spu销售属性列表
export const reqSpuSaleAttrList = (spuId:number)=>{
  return request.get<any,any>(`${Api.getSpuSaleAttrListApi}/${spuId}`)
}

//更新spu请求
export const reqUpdateSpuInfo = (spuInfo)=>{
  return request.post<any,any>(Api.updateSpuInfoApi,spuInfo)
}